// client.cpp
#define _WIN32_DCOM
#include <iostream.h>
#include "Container\container.h"

const CLSID CLSID_Container = {0x10000012,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01}};

void main()
{
	cout << "Client: Calling CoInitialize()" << endl;
	CoInitialize(NULL);

	IMultiply* pMultiply;

	cout << "Client: Calling CoCreateInstance() " << endl;
	CoCreateInstance(CLSID_Container, NULL, CLSCTX_INPROC_SERVER, IID_IMultiply, (void**)&pMultiply);

	cout << "Client: pMultiply = " << pMultiply << endl;
	HRESULT hr;

	int multiply;
	hr = pMultiply->Multiply(4, 3, &multiply);
	if(SUCCEEDED(hr))
		cout << "Client: Calling Multiply() return value is " << multiply << endl;

	ISum* pSum;
	pMultiply->QueryInterface(IID_ISum, (void**)&pSum);

	int sum;
	hr = pSum->Sum(4, 3, &sum);
	if(SUCCEEDED(hr))
		cout << "Client: Calling Sum() return value is " << sum << endl;

	cout << "Client: Calling Release() for pMultiply" << endl;
	hr = pMultiply->Release();
	hr = pSum->Release();

	cout << "Client: Calling CoUninitialize()" << endl;
	CoUninitialize();
}